package com.cedric.yixianpai.game.cards.Sects.swordCards.e_HuaShen;

import com.cedric.yixianpai.game.Constants.CardType;
import com.cedric.yixianpai.game.Constants.Period;
import com.cedric.yixianpai.game.Status.DuelStatus;
import com.cedric.yixianpai.game.interfaces.SwordCard;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class YuKongJianZhen extends SwordCard {
    /**
     * title:御空剑阵
     * effect:防>0则此牌无需灵气 防+8/14/20 再动
     */
    public YuKongJianZhen(@Value("1") int lvl) {
        super("御空剑阵");
        this.setLevel(lvl);
        this.setCardType(CardType.ZHEN);
        this.setPeriod(Period.HUASHEN);
        this.setDescription("灵气-1 防>0则此牌无需灵气 防+8/14/20 再次行动");

        this.setSpiritNeed(1);
        if (1 == lvl) {
            this.setShield(8);
        } else if (2 == lvl) {
            this.setShield(14);
        } else if (3 == lvl) {
            this.setShield(20);
        } else {
            throw new RuntimeException("Card Level Error!");
        }
    }

    @Override
    public boolean effect(DuelStatus Sta1, DuelStatus Sta2) {
        if(Sta1.getPlayerBuff().getShield()>0){
            Sta1.getPlayerBuff().addShield(this.getShield());
            Sta1.setAgain();
            return true;
        }else if(Sta1.spiritEnough(this.getSpiritNeed())){
            Sta1.getPlayerBuff().addShield(this.getShield());
            Sta1.setAgain();
            return true;
        }
        return false;
    }
}
